package com.lcf.order.client;

import com.lcf.order.config.Configuration2;
import com.lcf.order.dto.CartDTO;
import com.lcf.order.entity.ProductInfo;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;

import java.util.List;

@FeignClient(name = "productinfo",fallback = ProductClient.ProductClientHystrix.class)

//@FeignClient(name = "productinfo",configuration = Configuration2.class,fallback = ProductClient.ProductClientHystrix.class)
public interface ProductClient {

    @GetMapping("/msg")
    String productMsg();

    @PostMapping("/listForOrder")
    List<ProductInfo> productListForOrder(List<String> list);


    @PostMapping("/decreaseStock")
    void productDecreaseStock(List<CartDTO> cartDTOList);

    /**
     * 如果是用jar包的形式引入此类的,需要在启动类上配置包的扫描范围
     */
    @Component
    class ProductClientHystrix implements ProductClient {

        @Override
        public String productMsg() {
            return null;
        }

        @Override
        public List<ProductInfo> productListForOrder(List<String> list) {
            return null;
        }

        @Override
        public void productDecreaseStock(List<CartDTO> cartDTOList) {

        }
    }
}
